﻿
using B.S.Passport.Infacetrue;
using B.S.Passport.ErrorCode;

using B.S.Passport.Write.API.Application;
using MediatR;
using DAL;
using B.S.Passport.Domain;

namespace B.S.Passport.Write.API.ApplicationHander
{
    public class DelsWhouseCommandHander : IRequestHandler<DelsWhouseCommand, ApiResult<object>>
    {
        public readonly DBHelper1 dBHelper;
        public readonly IBaseRepository<WarehouseModel> baseRepository;

        public DelsWhouseCommandHander(DBHelper1 dBHelper, IBaseRepository<WarehouseModel> baseRepository)
        {
            this.dBHelper = dBHelper;
            this.baseRepository = baseRepository;
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<ApiResult<object>> Handle(DelsWhouseCommand request, CancellationToken cancellationToken)
        {
            ApiResult<object> apiResult = new ApiResult<object>();
            
           var r= dBHelper.BatchDeleteByIds($"{request.Table}", request.Id, request.ziduan);
            if (r>0)
            {
                apiResult.Code = (ApiEnums)Renum.删除成功;
                apiResult.Message = Renum.删除成功.ToString();
                apiResult.Data = r;
            }
            return Task.FromResult(apiResult);
        }
    }
}
